<extend name="Common@Layout:hui-admin" />
<block name="title"><title>应用私有用户-用户管理-Administator管理后台</title></block>
<block name="style">
</block>

<block name="main">
	<nav class="breadcrumb">
		<i class="Hui-iconfont"></i>
		 统计管理 <span class="c-gray en">&gt;</span>
		 人员统计
		<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont"></i></a>
	</nav>
	
	<div class="pd-20">
		<php>
			$g_did = R('Ygcl/Apiadmin/getxiaoqurole');
			if($g_did){
				$map['did'] = array('in',$g_did);
			}
		</php>
		<div class="text-c"> 
			<form status="{:u('index')}" method="get" id="form">
			学期：
			<span class="select-box inline">
			<select name="tid" class="select xiaoqu">
				<option value="">全部</option>
				<foreach name="xueqi" item="vo">
					<option value="{$vo.id}" <eq name="_GET['tid']" value="$vo['id']">selected</eq>>{$vo.title}</option>
				</foreach>
			</select>
			</span> 
			校区：
			<span class="select-box inline">
			<select name="did" class="select xiaoqu">
				<option value="">全部</option>
				<foreach name="xiaoqu" item="vo">
					<if condition="$g_did">
						<if condition="$g_did eq $vo['id']">
						<option value="{$vo.id}" <eq name="_GET['did']" value="$vo['id']">selected</eq>>{$vo.title}</option>
						</if>
					<else/>
						<option value="{$vo.id}" <eq name="_GET['did']" value="$vo['id']">selected</eq>>{$vo.title}</option>
					</if>
				</foreach>
			</select>
			</span> 
			<span>课程：</span>
			<span class="select-box inline">
			<select name="cid" class="select kecheng">
				
			</select>
			</span> 
			<span>班级：</span>
			<span class="select-box inline">
			<select name="lid" class="select banji">
				
			</select>
			</span> 
			<input type="hidden" name="classid" value="{$_GET['cid']}"/>
			<input type="hidden" name="lessonid" value="{$_GET['lid']}"/>
			<input type="hidden" name="p" value="1"/>
			<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜索</button>
			</form>
		</div>
		<php>
			if($_GET['did']==""){
				$_GET['cid']="";
				$_GET['lid']="";
			}
			if($_GET['cid']==""){
				$_GET['lid']="";
			}
			$map['status'] = 1;
			$result = _get_list_data('/count/index/index/',$_GET,$map,D('LessonStudentRelation'));
		</php>
		<form class="mini-form mt-20">
		<table class="table table-border table-bordered table-hover table-bg mini-sort">
			<thead>
				<tr>
					<th scope="col" colspan="12">共有{$result['data']['count']}位学生<a class="btn btn-primary radius ml-5" href="{:U('api/export',$_GET)}">导出数据并生成excel</a> </th>
				</tr>
				<tr class="text-c">
					<th width="25"><input type="checkbox" value="" name=""></th>
					<th width="40">ID</th>
					<th>姓名</th>
					<th>手机</th>
					<th>家长姓名</th>
					<th>学期</th>	
					<th>校区</th>				
					<th>课程</th>
					<th>班级</th>
					<th width="70">操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="result['data']['list']" item="vo">
				<tr class="text-c">
					<td><input type="checkbox" value="{$vo.id}" name="ids[]"></td>
					<td>{:replace_query_str($_GET['keywords'],$vo['id'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['student'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['tel'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['jzxm'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['term']['title'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['xiaoqu']['title'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['kecheng']['title'])}</td>
					<td>{:replace_query_str($_GET['keywords'],$vo['banji']['lessonname'])}</td>
					<td class="f-14">
						<if condition="$vo[orderid]">
						<a style="text-decoration:none" href="javascript:;" onclick="open_iframe_dialog('{:U('Ygcl/Orderadmin/detail',array(id=>$vo[orderid]))}','订单详情',['600px','600px'],1)" title="详情">订单详情</a>
						</if>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		</form>
		{$result['pagetpl']}
	</div>
<script id="option" type="text/html">
{{if classid == id}}
<option value="{{id}}" selected>{{title}}</option>
{{else}}
<option value="{{id}}">{{title}}</option>
{{/if}}
</script>
<script id="lesson" type="text/html">
{{if lessonid == id}}
<option value="{{id}}" selected>{{lessonname}}({{lessoncode}}{{lessontime}})</option>
{{else}}
<option value="{{id}}">{{lessonname}}({{lessoncode}}{{lessontime}})</option>
{{/if}}
</script>
</block>

<block name="script">
<script type="text/javascript" src="/Public/Assets/tpl/template.js"></script> 
<script>
$('#changeG').change(function(){
	window.location.href="/admin/Users/app/appid/"+$('#changeG').val();
});
$(function(){
	$('.mini-time').datepicker();
	
	if($(".xiaoqu").val()){
		$(".xiaoqu").trigger('change');
	}
	
});
$(".xiaoqu").change(function(){
	var did = $(this).val();
	if(did == ''){
		$(".kecheng").empty();
		$(".banji").empty();
		return false;
	}
	$.post('/count/api/getclass',{did:did},function(data){
		if(data.status){
			var classid = 0;
			$("input[name=classid]").val() ? classid = $("input[name=classid]").val():classid=0;
			var html="";
			var tmp=data.info;
			html = "<option value=''>全部</option>";
			for(var i = 0 ; i <tmp.length ; i++){
				tmp[i]['classid'] = classid;
				html += template('option',tmp[i]);
			}
			$(".kecheng").empty().append(html);
			if($(".kecheng").val()){
				$(".kecheng").trigger('change');
			}
		}
	})
})
$(".kecheng").change(function(){
	var cid = $(this).val();
	if(cid == ""){
		$(".banji").empty();
		return false;
	}
	$.post('/count/api/getlesson',{cid:cid},function(data){
		if(data.status){
			var lessonid = 0;
			$("input[name=lessonid]").val() ? lessonid = $("input[name=lessonid]").val():lessonid=0;
			var html="";
			var tmp=data.info;
			html = "<option value=''>全部</option>";
			for(var i = 0 ; i <tmp.length ; i++){
				tmp[i]['lessonid'] = lessonid;
				html += template('lesson',tmp[i]);
			}
			$(".banji").empty().append(html);
			
		}
	})
})
</script>
</block>